package org.whb.basic.Controller;


import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.whb.basic.service.IVerificationCodeService;
import org.whb.basic.util.AjaxResult;

import java.util.Map;

@RestController
@RequestMapping("/verifycode")
public class VerificationCodeController {

    @Autowired
    private IVerificationCodeService verificationCodeService;

    @PostMapping("/sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody Map<String,String> phone){
        try {
            verificationCodeService.sendSmsCode(phone);
            return new AjaxResult();
        } catch (RuntimeException e) {
            e.printStackTrace();
            return AjaxResult
                    .me()
                    .setSuccess(false)
                    .setMessage(e.getMessage());
        } catch (Exception e){
            return AjaxResult
                    .me()
                    .setSuccess(false)
                    .setMessage("服务器繁忙，请稍后再试！");
        }
    }


}
